package person;


import java.io.Serializable;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class PersonInfo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3L;
	private String firstName;
	private String secondName;
	private String placeOfBirth;
	Calendar birth;
	
	public PersonInfo (String firstName,String secondName,String placeOfBirth,int dayBirth,int monthBirth,int yearBirth){
		this.firstName=firstName;
		this.secondName=secondName;
		this.placeOfBirth=placeOfBirth;
		setBirth (dayBirth, monthBirth, yearBirth);
	}
	public PersonInfo (){}
	
	public void setFirstName (String input){
		firstName = input;
	}
	public void setSecondName (String input){
		secondName = input;
	}
	public String getFirstAndScndName (){
		return firstName+" "+secondName;
	}
	public void setPlaceOfBirth(String input){
		placeOfBirth=input;
	}
	public void setBirth (int day,int month,int year){
		
		birth = new GregorianCalendar (year,month,day);
	}
	public void setBirth (Calendar birth){
		this.birth = birth;
	}
	public String getFirstName (){
		return firstName;
	}
	public String getSecondName (){
		
		return secondName;
	}
	public String getPlaceOfBirth (){
		
		return placeOfBirth;
	}
	public Calendar getBirth (){
		if (birth != null){
			return birth;
		}
		System.out.println("Date not set.");
		return null;
	}
	@Override
	public boolean equals (Object obj1){
		PersonInfo obj = (PersonInfo) obj1;
		
		if (obj.getFirstName().equals(firstName)){
			if (obj.getSecondName().equals(secondName)){
				if (obj.getBirth().equals(birth)){
					return true;
				}
			}
		}
		return false;

	}
}
